import request from "@/utils/request";

// // 注册
// export const userRegisterService = ({
//   username,
//   password,
//   repassword,
//   codeKey,
// }) => {
//   return request.post("/api/reg", { username, password, repassword, codeKey });
// };

// 获取图形验证码
export const userGetCaptchaService = () => {
  return request.get("/admin/index/generateValidateCode");
};

// 登录
export const userLoginService = ({ captcha, codeKey, password, username }) => {
  return request.post("/admin/index/login", {
    captcha,
    codeKey,
    password,
    username,
  });
};

// 获取用户信息
export const userGetInfoService = () => {
  return request.get("/admin/index/info");
};
// // 获取用户权限信息
// export const userGetInfoAuthorityService = () => {
//   return request.get("/admin/index/info");
// };

// 更新用户信息
export const userUpdateInfoService = ({ id, nickname, email }) => {
  return request.put("/my/userinfo", { id, nickname, email });
};

// 上传用户头像
export const userUploadAvatarService = (avatar) => {
  return request.patch("/my/update/avatar", { avatar });
};

// 更新密码
export const userUpdatePassService = ({ newPassword, truePassword }) => {
  return request.put("/admin/index/updatePassword", {
    newPassword,
    truePassword,
  });
};

// 获取所有头像列表
export const userGetAvatarListService = () => {
  return request.get("/avatars");
};
